package com.sky.utils;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author normal
 * @date 2025年03月06日 下午1:11
 */
public class DateUtil {


    public static List<LocalDate> getBetweenDates(LocalDate start, LocalDate end) {
        return getBetweenDates(start, end,true);
    }

    public static List<LocalDate> getBetweenDates(LocalDate start, LocalDate end, Boolean isIncludeEnd) {

        // 校验时间参数
        if (start == null || end == null) {
            return new ArrayList<LocalDate>();
        }

        if (start.isAfter(end)){
            // 直接返回一个空集合
            return new ArrayList<LocalDate>();
        }


        List<LocalDate> result = new ArrayList<>();
        LocalDate temp = start;
        while (temp.isBefore(end)) {
            result.add(temp);
            temp = temp.plusDays(1);
        }
        if (isIncludeEnd){
            result.add(end);
        }

        return result;
    }
}
